<template>
  <div>
    <div class="register">
      <img :src="require('../../assets/img/logo.png')" alt="" />
    </div>

     <van-form @submit="register">
      <van-field
        v-model="user.phone"
        name="手机号"
        label="手机号"
        placeholder="手机号"
        :rules="[{ required: true, message: '请填写手机号' }]"
      />
       <van-field
        v-model="user.nickname"
        name="昵称"
        label="昵称"
        placeholder="昵称"
        :rules="[{ required: true, message: '请填写昵称' }]"
      />
      <van-field
        v-model="user.password"
        type="password"
        name="密码"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button round block type="danger" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
// import axios from 'axios'
import {reqregister} from "../../http/http";
export default {
  data() {
    return {
      user: {
        phone: "",
        nickname: "",
        password: "",
      },
    };
  },
  methods: {
    register() {
      reqregister(this.user).then((res) => {
        console.log(res); //查看数据
        if (res.data.code === 200) {
          alert(res.data.msg);
          this.$router.push("/login");
        } else {
          alert(res.data.msg);
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
@import "../../less/index.less";
.register img {
  // width: 3.63rem;
  // height: 0.96rem;
  margin: 1.5rem auto;
}
.user,
.nick,
.psw {
  width: 6rem;
  height: 0.6rem;
  margin: 0 auto;
  text-align: center;
  color: #000;
}
.btn {
  display: block;
  text-align: center;
  padding: 0;
  margin: 0;
  width: 1.5rem;
  margin: 0.5rem auto;
}
</style>